using System.ComponentModel.DataAnnotations;

namespace RiceShop.Models
{
    /// <summary>
    /// 退款记录模型
    /// </summary>
    public class RefundRecord
    {
        /// <summary>
        /// 退款记录ID
        /// </summary>
        [Key]
        public int RefundId { get; set; }

        /// <summary>
        /// 订单ID
        /// </summary>
        public long OrderId { get; set; }

        /// <summary>
        /// 支付记录ID
        /// </summary>
        public int PaymentId { get; set; }

        /// <summary>
        /// 订单号
        /// </summary>
        [Required]
        [StringLength(50)]
        public string OrderNo { get; set; } = string.Empty;

        /// <summary>
        /// 退款单号（商户内部退款单号）
        /// </summary>
        [Required]
        [StringLength(50)]
        public string RefundNo { get; set; } = string.Empty;

        /// <summary>
        /// 微信退款单号
        /// </summary>
        [StringLength(50)]
        public string? WxRefundId { get; set; }

        /// <summary>
        /// 退款金额
        /// </summary>
        [Required]
        public decimal RefundAmount { get; set; }

        /// <summary>
        /// 退款状态
        /// 0-处理中 1-退款成功 2-退款失败 3-已撤销
        /// </summary>
        public int RefundStatus { get; set; }

        /// <summary>
        /// 退款原因
        /// </summary>
        [StringLength(200)]
        public string? RefundReason { get; set; }

        /// <summary>
        /// 退款时间
        /// </summary>
        public DateTime? RefundTime { get; set; }

        /// <summary>
        /// 退款失败原因
        /// </summary>
        [StringLength(200)]
        public string? FailReason { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 关联的订单
        /// </summary>
        public virtual Order? Order { get; set; }

        /// <summary>
        /// 关联的支付记录
        /// </summary>
        public virtual PaymentRecord? PaymentRecord { get; set; }
    }

    /// <summary>
    /// 退款状态枚举
    /// </summary>
    public enum RefundStatus
    {
        /// <summary>
        /// 处理中
        /// </summary>
        Processing = 0,

        /// <summary>
        /// 退款成功
        /// </summary>
        Success = 1,

        /// <summary>
        /// 退款失败
        /// </summary>
        Failed = 2,

        /// <summary>
        /// 已撤销
        /// </summary>
        Cancelled = 3
    }
} 